-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS compilation error #3826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The compilation error appeared after KT-59665
MR in Kotlin: https://jetbrains.team/p/kt/reviews/11039/timeline |
@@ -54,6 +54,7 @@ public actual typealias TestResult = Unit | |||
* } | |||
* ``` | |||
*/ | |||
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS") // Counterpart for ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on how we should proceed further with this suppress?
If this case is no longer supported (or was unsupported but not explicitly reported), shouldn't we have any kind of migration plan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This suppress is a counterpart for @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
. You can see that you already have a @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
inside public actual open class TestBase
.
If you didn't have @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
then NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS
wouldn't be reported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I had to rework the way we report ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS
. Before my changes, it was a separate checker. Now it's checked in the expect-actual matcher and it's considered a common expect-actual mismatch incompatibility
And such types of expect-actual mismatch incompatibilities are reported two times:
// Common
expect class Bar {
fun foo(): Any
}
// Platform
actual class Bar { // NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS (first time)
actual fun foo(): String { // ACTUAL_WITHOUT_EXPECT (second time)
return ""
}
}
That's why you need to suppress ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS
two times (But they are two separate diagnostics)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it will be more clear If I change Counterpart for ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS
comment to Counterpart for @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full compilation error of NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS
also makes it clear:
e: file:///home/bobko/jb/test-proj/kotlinx.coroutines/kotlinx-coroutines-core/jvm/test/TestBase.kt:57 Actual class 'TestBase' has no corresponding members for expected class members:
public expect fun error(message: Any, cause: Throwable?): Nothing
The following declaration is incompatible because actual function cannot have default argument values, they should be declared in the expected function:
public actual fun error(message: Any, cause: Throwable? = null): Nothing
Let's please wait for the accept in https://jetbrains.team/p/kt/reviews/11039/timeline before merging. Maybe the plan will change. I will ping you here once the status of the https://jetbrains.team/p/kt/reviews/11039/timeline changes |
The review in Kotlin is done. @qwwdfsad can you please merge it? (please note the @mshishkina can you please cherry-pick it to |
The compilation error appeared after KT-59665
The compilation error appeared after KT-59665
The compilation error appeared after KT-59665